home *** CD-ROM | disk | FTP | other *** search
- Path: rain.fr!world-net!usenet
- From: Juniet Christophe <chris@lmm.com>
- Newsgroups: comp.os.linux.setup,comp.os.linux.misc,comp.os.linux,comp.lang.c,comp.lang.c++
- Subject: Re: problems with GCC
- Date: Sat, 20 Apr 1996 13:33:56 +0200
- Organization: Le Monde Mobile
- Message-ID: <3178CBA4.2E841546@lmm.com>
- References: <4l1and$iql@news.ran.es>
- NNTP-Posting-Host: pm9-004.sct.fr
- Mime-Version: 1.0
- Content-Type: text/plain; charset=iso-8859-1
- Content-Transfer-Encoding: quoted-printable
- X-Mailer: Mozilla 2.0 (X11; I; Linux 1.2.13 i586)
-
- Chano G=F3mez Mart=EDnez wrote:
- > =
-
- > First of all, I want to apologize for my awful English.
-
- I should say the same ;^)
-
- > Now, the C stuff :
- > =
-
- > I'm trying to port a C program from Borland C++ 3.1 to GCC under
- > Linux.
- > My problem is that I can't use any function from math.h !!!
- > The file is correctly #include'd ( in fact, I get no compilation
- > errors ) but the linker always tells me something like :
- > =
-
- > /tmp/cca000971.o(.text+0x39): undefined reference to `exp'
- > =
-
- > The funny thing is that GPC ( the GNU Pascal compiler ) allows me to
- > use math.h functions lihe exp(), sin(), fabs(), etc, but when I
- > convert my Pascal programs to C with p2c and try to compile them with
- > GCC , I get the same error again.
- > =
-
- > Here is the result from compiling the Pascal source with GPC -v ...
- > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
- =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
- >
- (...messages from gpc...)
-
- > -L/usr/i486-linux/lib /tmp/cca001031.o -lgpc -lgcc -lm -lc -lg
- Here it is! ^^^^^^
-
- (...messages from gcc...)
- >
- > The only apparent difference between both results is in the libraries
- > ( I think)
- > Can anyone help me, please ???
- > =
-
-
- When you compile some code, you need to link it to the right libraries.
- For instance, you need to link your program with the library libm which
- is for math.
- Try `gcc ... -lm`. In general, for foo.h try -lfoo, but you'd better
- check /lib or /usr/lib.
-
- > Thanks in advance.
- Hope this helps :)
-
- -- =
-
- Christophe Juniet =
-
- chris@lmm.com =
-
- Un Linux, s'il vous pla=EEt!
- (A Linux, please!)
-